package cn.cupk.entities;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;


@Data
public class CreatureCollections implements DataAceess{

    private List<Creature> creatures;

    public CreatureCollections() {
        this.creatures = new ArrayList<>(); // 初始化creatures列表
    }

    @Override
    public void addCreature(Creature creature) {
        creatures.add(creature);
    }

    @Override
    public void removeCreature(Creature creature) {
        creatures.remove(creature);
    }

    @Override
    public void updateCreatureHealthStatus(Creature creature, String healthStatus) {
        creature.setHealthStatus(healthStatus);
    }

    @Override
    public Creature findCreatureByName(String name) {
        for (Creature creature : creatures) {
            if (creature.getName().equals(name)) {
                return creature;
            }
        }
        return null;
    }
}

